package com.example.lanouhn.bantangapp.activities.utils;


import com.example.lanouhn.bantangapp.activities.contants.LoginNP;
import com.example.lanouhn.bantangapp.activities.contants.LoginSet;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * 解析Json数据
 */
public class JsonUtils_LoginSet {

    /**
     * @param json json字符串
     * @return 登录
     */
    public static List<LoginSet> getlloginList(String json) {
        List<LoginSet> list = new ArrayList<>();
        try {
            JSONObject jsonObject = new JSONObject(json);


            JSONObject object =jsonObject.getJSONObject("data");

            for (int i = 0; i < object.length(); i++) {
                JSONObject j = object.getJSONObject(String.valueOf(i));


                LoginSet m = new LoginSet();
                m.setAccess_token(j.getString("access_token"));
                m.setUser_id(j.getString("user_id"));
                m.setNickname(j.getString("nickname"));
                m.setAvatar(j.getString("avatar"));
                list.add(m);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }
}
